/**
 * @license
*
* PreProcessing is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PreProcessing is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PreProcessing.  If not, see <http://www.gnu.org/licenses/>.
* 
*/

/**
 * @mainpage 
 * 
 * @author  <ul>
 *            <li>Grant</li>
 *            <li>Priya</li>
 *            <li>Ash</li>
 *          </ul>
 */

package SmartGrid;

import java.io.Serializable;

/**
 * @class Meter
 * @brief Meter is the main class that consumer devices will connect to
 * @author Grant Hewton
 * @version 1.1 
 */
public class Meter{
    
    private int meterID;
    private int connectedDeviceID;
    private String ledDisplay = "";
    //private enum Status{INITIALISE, CHECKING, SENDING, RECEIVING};

       
    private enum COMM {SUCCESS, FAILURE, ERROR, INIT, REQUEST, RESPONSE, MISC};
    private enum STATUS {OPERATIONAL, MALFUNCTION, ERROR, INIT, INTERNAL_HW_CHECK, INTERNAL_SW_CHECK};
    
    private STATUS status;
    private COMM comm;
    
    /*switch(comm)
    {
        case COMM.INIT:
    }*/
    
    private static int numberOfMeters = 0;
    
    /** 
     * @brief Default constructor
     * 
     * Constructs a new meter object
     */
    public Meter() 
    {     
        
        meterID = ++numberOfMeters;
        //System.out.println(meterID);
        status = STATUS.INIT;
        //System.out.println(status);
        
    }
    
    
    /** 
     * @brief Meter constructor
     * 
     * Constructs a new log file of type Log
     */
    /*public Meter(int deviceID) 
    {        
        logDeviceID = deviceID;
        logStartDateTime = Log.getDateTime();
        logID = ++numberOfLogs;
    }*/
    
    /**
     *  @brief Set the meter status
     * @param newStatus 
     */    
    public void setSTATUS(STATUS newStatus)
    {
        status = newStatus;
    }
    
    /**
     *  @brief Get the meter status
     *  @return status 
     */    
    public STATUS getStatus()
    {
        return status;
    }
    
    /**
     *  @brief Set the LED display on the meter 
     * 
     * @param output is a String that is used to set the led display
     */    
    public void setLedDisplay(String output)
    {
        ledDisplay = output;
    }
    
    /**
     *  @brief get the meterID 
     * 
     * @param output is a String that is used to set the led display
     */    
    public int getMeterID()
    {
        return meterID;
    }
    
    /**
     * @brief Perform self check of the meter
     * 
     * The meter runs through set maintenance examinations to ensure that 
     * it is functioning correctly and is up to date with the server
     * 
     */
    public boolean doSelfCheck()
    {
        boolean SelfCheckComplete = true;
        
        
        return SelfCheckComplete;
    }  
    
    /**
     * @brief method to add a device to the meter
     * 
     */    
    public void addDevice(int deviceID)
    {
        connectedDeviceID = deviceID;
    }
    
    public void removeDevice(int deviceID)
    {
        
    }
}

